﻿<!--#include file="const.inc"-->
<%
'====================================================================
' 感谢使用晴天3G智能建站系统..
' 作者:梁永强.QQ:766750857
' 官方网址:wap.qt3g.com
' 声明:软件版权归作者所有,没有经过作者本人同意不得非法破解和传播本程序
'====================================================================
%>

<%	dim rs,sql,i,id,zf,down,nid,gm,viphy,viphy2,zf2,FileUrl,listid,DownTime


	id=Request.QueryString("id")
	if id="" then id=0
	if not isnumeric(id) then id=0
	id=clng(id)

	Set Rs = Server.CreateObject("Adodb.Recordset")



	if sid<>"Null" then


	Set Rs = Server.CreateObject("Adodb.Recordset")

	Sql = "select vip,id from qingtian_user where sid='"&md5(sid) & md5(strReverse(sid))&"'"
	Rs.Open Sql,conn,1,1

	if not (rs.bof and rs.eof)  then
		viphy=rs("vip")
		nid=rs("id")
	end if
	Rs.close	

	Sql = "select id from qingtian_paym where ext=3 and listid="&id&" and  nid="&nid&""
	Rs.Open Sql,conn,1,1
	if not (rs.bof and rs.eof)  then
		gm=1
	else
		gm=0
	end if
	Rs.close	


	else
		gm=0
		viphy=0
	end if




	Sql = "select urls,listid from qingtian_photo_down where id="&id
	Rs.Open Sql,conn,1,1
	if not (rs.bof and rs.eof)  then
		FileUrl=rs("urls")
		listid=rs("listid")
	end if
	Rs.close	





	Sql = "select VIP,zf,viphy,vipgm,DownTime from qingtian_photoli where id="&listid
	Rs.Open Sql,conn,1,1
	if not (rs.bof and rs.eof)  then

		viphy2=rs("viphy")
		zf2=rs("zf")
		DownTime=rs("DownTime")


		if viphy=1 then
			if rs("vipgm")=1 then
				if gm=1 then
					down=true
				else
					down=false
				end if

			else
				down=true
			end if
		elseif rs("viphy")=1 then
			down=false
		elseif rs("vip")=1 then
				if gm=1 or rs("zf")=0 then
					down=true
				else
					down=false
				end if
		else
			down=true

		end if

	end if
	Rs.close	
	set rs=nothing


		if down=true then
               	 	conn.execute("update qingtian_photoli set [downcount]=[downcount]+1,[downtime]='" & Now() & "' where [id]=" & listid & "")

            		If DateDiff("m", downtime, Now()) > 0 Then
               	 		conn.execute("update qingtian_photoli set [Monthdown]=1 where [id]=" & listid & "")
            		Else
                		conn.execute("update qingtian_photoli set [Monthdown]=[Monthdown]+1 where [id]=" & listid & "")
            		End If

            		If DateDiff("ww", downtime, Now()) > 0 Then
                		conn.execute("update qingtian_photoli set [Weekdown]=1 where [id]=" & listid & "")
            		Else
                		conn.execute("update qingtian_photoli set [Weekdown]=[Weekdown]+1 where [id]=" & listid & "")
            		End If

            		If DateDiff("d", downtime, Now()) > 0 Then
                		conn.execute("update qingtian_photoli set [Daydown]=1 where [id]=" & listid & "")
           		Else
                		conn.execute("update qingtian_photoli set [Daydown]=[Daydown]+1 where [id]=" & listid & "")
            		End If


select case v
case "0"
we0="<br/>"
%>
<card title="图片下载" ontimer="<%=qingtian.utf8(FileUrl)%>"><timer value="30"/><p align="<%=qingtian.px%>">
<%
case "1"
hr="<hr>"
zi="<span style=""color:#FF5500"">"
zi0="</span>"
we="<div class=""footer"">"
sou="<div class=""block4"">"
dao="<div class=""navi"">"
we0="</div>"
%>
<title>图片下载</title>
</head>
<body>
<!--#include virtual="/css.inc"-->
<%

End Select
%><%

		if sid="Null" then
			%><%=we%><%=zi%>欢迎你<%=zi0%><a href="login.asp?sid=<%=sidd%>&amp;url=down.asp?id=<%=id%>@@v=<%=v%>@@fv=<%=fv%>@@sid=<%=sidd%>">注册/登陆</a<%=we0%><%
			else
			qingtian.info
			end if

			%><%=we%>正在自动下载图片!如果无法自动下载,请<a href="<%=qingtian.utf8(FileUrl)%>">手动下载</a><%=we0%><%
			else
if viphy2=1 then
                        if viphy=1  then


			%><%=we%>你还没有购买!,购买需金币<%=zf2%><%=we0%><%
			end if
		else

			if sid<>"Null" then
				%><%=we%>你还没有购买,购买需金币<%=zf2%>!<%=we0%><%=sou%><a href="paym.asp?ext=1&amp;id=<%=id%>&amp;sid=<%=sidd%>">马上购买</a><%=we0%><%
			else
				%><%=we%>下载图片出错!该图片为会员下载.请先登陆再下载!<%=we0%><%
			end if
                      end if
end if
   		    %><%=sou%><%Response.Write("<a href='photove.asp?id="&listid&"&amp;sid="&sidd&"'>返回查看图片</a>")%><%=we0%><%

   		    Response.Write(""&dao&"<a href='index.asp?sid="&sidd&"'>网站首页</a>")

end Function
%>
